using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace TidhiGanitam.DataModel
{
    public class DurmuhurtamuRoutineItem
    {
        private int m_Year;
        DateTime m_Date;
        private int m_SNo;
        private DinamuRoutineItem m_DinamuRoutine;
        private ArrayList m_DurmuhurtamuDetials;

        public int Bhagamu
        {
            get
            { return m_SNo; }
            set
            { m_SNo = value; }
        }
        public DateTime Date
        {
            get { return m_Date; }
        }
        public ArrayList DurmuhurtamuDetails
        {
            get
            {return m_DurmuhurtamuDetials;}
            set
            {m_DurmuhurtamuDetials = value;}
        }
        public DurmuhurtamuRoutineItem(int SNo, int Year, DateTime Date, DinamuRoutineItem CurrentDinamuRoutine)
        {
            m_SNo = SNo;
            m_Year = Year;
            m_Date = Date;
            m_DinamuRoutine = CurrentDinamuRoutine;
            m_DurmuhurtamuDetials = new ArrayList();
        }
        public void Calculate()
        {
            Rasi DinaPramanam = new Rasi(m_DinamuRoutine.DinaPramanam);
            Rasi Suryodayamu = new Rasi(m_DinamuRoutine.Suryodayam);
            Rasi Suryastamamu = new Rasi(m_DinamuRoutine.Suryastamam);
            Rasi Span = new Rasi(DinaPramanam / 15);
            Rasi SpanHrs = new Rasi(Span * Constants.RasiTimeConversionFactor);
            switch (m_DinamuRoutine.Date.DayOfWeek)
            {
                case DayOfWeek.Sunday:
                    {
                        //14th part - Day
                        DurmuhurtamuDetails DrMuhurtamu = new DurmuhurtamuDetails();
                        Rasi CalcPart = new Rasi(DinaPramanam * 13 / 15);
                        DrMuhurtamu.StartTime = new Rasi(CalcPart);
                        DrMuhurtamu.EndTime = DrMuhurtamu.StartTime + Span;
                        DrMuhurtamu.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Sayantramu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu);
                    }
                    break;
                case DayOfWeek.Monday:
                    {
                        //9th part, 12th part - Day
                        DurmuhurtamuDetails DrMuhurtamu = new DurmuhurtamuDetails();
                        Rasi CalcPart = new Rasi(DinaPramanam * 8 / 15);
                        DrMuhurtamu.StartTime = new Rasi(CalcPart);
                        DrMuhurtamu.EndTime = DrMuhurtamu.StartTime + Span;
                        DrMuhurtamu.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Madhyahnamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu);

                        //12th part - Day
                        DurmuhurtamuDetails DrMuhurtamu2 = new DurmuhurtamuDetails();
                        Rasi CalcPart2 = new Rasi(DinaPramanam * 11 / 15);
                        DrMuhurtamu2.StartTime = new Rasi(CalcPart2);
                        DrMuhurtamu2.EndTime = DrMuhurtamu2.StartTime + Span;
                        DrMuhurtamu2.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu2.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu2.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu2.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Madhyahnamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu2);
                    }
                    break;
                case DayOfWeek.Tuesday:
                    {
                        //4th part - Day 
                        DurmuhurtamuDetails DrMuhurtamu = new DurmuhurtamuDetails();
                        Rasi CalcPart = new Rasi(DinaPramanam * 3 / 15);
                        DrMuhurtamu.StartTime = new Rasi(CalcPart);
                        DrMuhurtamu.EndTime = DrMuhurtamu.StartTime + Span;
                        DrMuhurtamu.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Udayamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu);

                        //7th part - Ratri
                        DurmuhurtamuDetails DrMuhurtamu2 = new DurmuhurtamuDetails();
                        Rasi CalcPart2 = new Rasi(DinaPramanam * 6 / 15);
                        DrMuhurtamu2.StartTime = new Rasi(CalcPart2);
                        DrMuhurtamu2.EndTime = DrMuhurtamu2.StartTime + Span;
                        DrMuhurtamu2.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu2.StartTimeInHours = new Rasi(Suryastamamu +
                            (DrMuhurtamu2.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.EndTimeInHours = new Rasi(Suryastamamu +
                            (DrMuhurtamu2.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu2.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu2.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Ratri;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu2);
                    }
                    break;
                case DayOfWeek.Wednesday:
                    {
                        //8th part
                        DurmuhurtamuDetails DrMuhurtamu2 = new DurmuhurtamuDetails();
                        Rasi CalcPart = new Rasi(DinaPramanam * 7 / 15);
                        DrMuhurtamu2.StartTime = new Rasi(CalcPart);
                        DrMuhurtamu2.EndTime = DrMuhurtamu2.StartTime + Span;
                        DrMuhurtamu2.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu2.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu2.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu2.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Madhyahnamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu2);
                    }
                    break;
                case DayOfWeek.Thursday:
                    {
                        //6th part, 12th part
                        DurmuhurtamuDetails DrMuhurtamu = new DurmuhurtamuDetails();
                        Rasi CalcPart = new Rasi(DinaPramanam * 5 / 15);
                        DrMuhurtamu.StartTime = new Rasi(CalcPart);
                        DrMuhurtamu.EndTime = DrMuhurtamu.StartTime + Span;
                        DrMuhurtamu.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Udayamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu);

                        //12th part - Day
                        DurmuhurtamuDetails DrMuhurtamu2 = new DurmuhurtamuDetails();
                        Rasi CalcPart2 = new Rasi(DinaPramanam * 11 / 15);
                        DrMuhurtamu2.StartTime = new Rasi(CalcPart2);
                        DrMuhurtamu2.EndTime = DrMuhurtamu2.StartTime + Span;
                        DrMuhurtamu2.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu2.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu2.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu2.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Madhyahnamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu2);
                    }
                    break;
                case DayOfWeek.Friday:
                    {
                        //4th part, 9th part
                        DurmuhurtamuDetails DrMuhurtamu = new DurmuhurtamuDetails();
                        Rasi CalcPart = new Rasi(DinaPramanam * 3 / 15);
                        DrMuhurtamu.StartTime = new Rasi(CalcPart);
                        DrMuhurtamu.EndTime = DrMuhurtamu.StartTime + Span;
                        DrMuhurtamu.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Udayamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu);

                        //9th part - Day
                        DurmuhurtamuDetails DrMuhurtamu2 = new DurmuhurtamuDetails();
                        Rasi CalcPart2 = new Rasi(DinaPramanam * 8 / 15);
                        DrMuhurtamu2.StartTime = new Rasi(CalcPart2);
                        DrMuhurtamu2.EndTime = DrMuhurtamu2.StartTime + Span;
                        DrMuhurtamu2.DurmuhurtamuSpan = new Rasi(Span);

                        DrMuhurtamu2.StartTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.StartTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.EndTimeInHours = new Rasi(Suryodayamu +
                            (DrMuhurtamu2.EndTime * Constants.RasiTimeConversionFactor));
                        DrMuhurtamu2.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu2.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu2.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Madhyahnamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu2);
                    }
                    break;
                case DayOfWeek.Saturday:
                    {
                        //2 parts from suryodayamu
                        DurmuhurtamuDetails DrMuhurtamu = new DurmuhurtamuDetails();
                        DrMuhurtamu.StartTime = new Rasi(Suryodayamu * 5 / 2d);
                        DrMuhurtamu.StartTimeInHours = new Rasi(DrMuhurtamu.StartTime * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.EndTime = DrMuhurtamu.StartTime + Span * 2;
                        DrMuhurtamu.EndTimeInHours = new Rasi(DrMuhurtamu.EndTime * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.DurmuhurtamuSpan = new Rasi(Span * 2);
                        DrMuhurtamu.DurmuhurtamuSpanInHours
                            = new Rasi(DrMuhurtamu.DurmuhurtamuSpan * Constants.RasiTimeConversionFactor);
                        DrMuhurtamu.DurmuhurtaSamayamu = Enums.DurmuhurtamuSamayamu.Udayamu;
                        m_DurmuhurtamuDetials.Add(DrMuhurtamu);
                    }
                    break;
            }
        }
    }
}
